/**
 * 
 */
package cn.miao.learn.ssh.api;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.miao.learn.ssh.api.beans.Group;

@Path("/user")
public class UserResource {
	Log log = LogFactory.getLog(UserResource.class);

	@POST
	@Path("login")
	public String login(@FormParam("username") String username) {
		return "good 好";
	}

	@GET
	@Path("login2")
	public Response login2() {
		Response response = Response.status(200).entity("{\"name\":\"中宁io.\"}")
				.header("Content-Type", "application/json; charset=utf-8")
				.build();
		return response;
	}

	@GET
	@Path("login3")
	@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public Group login3() {
		Group group = new Group();
		group.setId(32);
		group.setName("fd地方");
		return group;
	}

	@GET
	@Produces("application/json; charset=utf-8")
	@Path("login4")
	public String login4() {
		return "{\"name\":\"中宁io.\"}";
	}

}
